package com.dragon.repository.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dragon.repository.entity.VendorProducts;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 供应商产品 Mapper 接口
 * </p>
 *
 * @author sy
 * @since 2023-08-16
 */
@Mapper
public interface VendorProductsMapper extends BaseMapper<VendorProducts> {

    @Select("<script> " +
            "select M.* from (" +
            "SELECT a.*, c.`name` AS unitName FROM `dragon_vendor_products` a " +
            "LEFT JOIN dragon_dictsort_detail c ON c.code_type = 'unitCode' AND a.unit = c.id )M WHERE 1=1 " +
            "<if test='search!=null and search != \"\"'>"+
            " AND M.`name` like CONCAT('%',#{search},'%')" +
            "</if>" +
            " order by M.id desc"+
            "</script> ")
    Page<VendorProducts> selectDailPage(Page<VendorProducts> VpPage,String search);
}
